﻿using IBaseRepository;
using IBaseService;
using SqlSugar;
using System.Linq.Expressions;

namespace BaseService
{
	public class BaseService<T>:IBaseService<T> where T : class,new()
	{
		protected IBaseRepository<T> baseRepository;

		public async Task<bool> CreateAsync(T tableType)
		{
			return await baseRepository.CreateAsync(tableType);
		}

		public async Task<bool> DeleteByIdAsync(int id)
		{
			return await baseRepository.DeleteByIdAsync(id);
		}

		public async Task<bool> EditAsync(T tableType)
		{
			return await baseRepository.EditAsync(tableType);
		}

		public async Task<T> FindByIdAsync(int key)
		{
			return await baseRepository.FindByIdAsync(key);
		}

		public async Task<List<T>> QueryAsync()
		{
			return await baseRepository.QueryAsync();
		}

		public async Task<List<T>> QueryAsync(Expression<Func<T, bool>> func)
		{
			return await baseRepository.QueryAsync(func);
		}

		public async Task<List<T>> QueryAsync(int PageIndex, int PageSize, RefAsync<int> Total)
		{
			return await baseRepository.QueryAsync(PageIndex,PageSize,Total);
		}

		public async Task<List<T>> QueryAsync(Expression<Func<T, bool>> func, int PageIndex, int PageSize, RefAsync<int> Total)
		{
			return await baseRepository.QueryAsync(func,PageIndex,PageSize,Total);
		}
	}
}
